using System;
using Glue;
using Glue.Internals.Verification;
using GlueTests.Builders;
using Xunit;

namespace GlueTests.RelationsVerificationTests
{
    public class When_all_RightTypeProperties_are_related_but_not_all_LeftTypeProperties
    {
        private readonly RelationsVerification<DomainPerson, GuiPerson> relationsVerification;

        public class DomainPerson
        {
            public String FirstName { get; set; }
            public String LastName { get; set; }
        }

        public class GuiPerson
        {
            public int Id { get; set; }
            public String FirstName { get; set; }
            public String LastName { get; set; }
        }

        public When_all_RightTypeProperties_are_related_but_not_all_LeftTypeProperties()
        {
            var mapping = new Mapping<DomainPerson, GuiPerson>();
            mapping.AutoRelateEqualNames();
            relationsVerification = new RelationsVerification<DomainPerson, GuiPerson>(mapping, new ObjectMemberFactoryBuilder().Build());
        }

        [Fact]
        public void Should_verify_not_all_RightTypePropertiesAreRelated()
        {

            Assert.Throws(typeof(GlueException),()=> relationsVerification.AssertAllPropertiesRelated<GuiPerson>());
        }

        [Fact]
        public void Should_verify_all_LeftTypePropertiesAreRelated()
        {
            relationsVerification.AssertAllPropertiesRelated<DomainPerson>();
        }
    }
}